<template>
  <div class="feed-container">
    <a-list
      class="demo-loadmore-list"
      :loading="loading"
      item-layout="vertical"
      :data-source="itemList.value"
    >
      

      <template #renderItem="{ item }">
        <a-list-item
          key="item.a_order"
          style="min-height: 100px; max-height: 300px"
        >
          <template #actions>
            <span :key="LikeOutlined">
              <component v-bind:is="LikeOutlined" style="margin-right: 8px" />
              {{ item.like_count }}
            </span>
            <span :key="MessageOutlined">
              <component
                v-bind:is="MessageOutlined"
                style="margin-right: 8px"
              />
              {{ item.comment_count }}
            </span>
            <span :key="StarOutlined">
              <component v-bind:is="StarOutlined" style="margin-right: 8px" />
              {{ item.sub_count }}
            </span>
            <span :key="'Author'" >
              <a-avatar style="margin-right: 8px"
                v-if="item.u_avatar"
                :src="'/api/avatar/' + item.u_avatar"
              />
              <a-avatar v-else style="margin-right: 8px">
                <template #icon>
                  <UserOutlined />
                </template>
              </a-avatar>
              {{item.u_name}}
            </span>
          </template>

          <a-list-item-meta>
            <template #title>
              <a :href="'/user/articledetail?a_id=' + item.a_id">{{
                item.a_title
              }}</a>
            </template>
          </a-list-item-meta>

          <div>{{ item.a_html }}</div>
          <div>
            <a-image height="60px" v-for="url in item.imglist" :key="url" :src="url"/>
          </div>
        </a-list-item>
      </template>
    </a-list>
  </div>
</template>

<script>
import { get, post, tip } from "@/common";
import { defineComponent, ref, reactive } from "vue";
import {
  StarOutlined,
  LikeOutlined,
  MessageOutlined,
} from "@ant-design/icons-vue";

const itemList = reactive({});
const getFeed = () => {
  get("/user/feed/getfollow").then((res) => {
    itemList.value = res.data;
  });
};

const actions = [
  {
    type: "LikeOutlined",
  },
  {
    type: "MessageOutlined",
  },
];

const infoData = ref({});
const getInfo = () => {
  get("/user/home/curr-user").then((res) => {
    infoData.value = res.data;
  });
};
getInfo();

export default defineComponent({
  setup() {
    getFeed();
    getInfo();
    //const { dataList, loading, loadingMore, loadMore } = useLoadMore(getFakeData, {listKey: 'results',});
    return {
      StarOutlined,
      LikeOutlined,
      MessageOutlined,
      getFeed,
      itemList,
    };
  },
});
</script>
<style>
.demo-loadmore-list {
  padding: 1% 5% 0 5%;
  
}
</style>